package com.dts.backproject.controller;

import com.dts.backproject.entity.po.Result;
import com.dts.backproject.entity.po.UserInfo;
import com.dts.backproject.service.UserInfoService;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userinfo")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @GetMapping("/select")
    public UserInfo selectByEmail(@RequestParam String email) {
        UserInfo userInfo= userInfoService.findByEmail(email);
        return userInfo;
    }

    @PostMapping("/add")
    public Result saveByEamil(@RequestBody UserInfo userInfo){
        userInfoService.add(userInfo);
        return Result.success("添加成功");
    }

    @PostMapping("/update")
    public void updateByEamil(@RequestBody UserInfo userInfo){
        userInfoService.update(userInfo);
    }
}
